

package com.loong.loong.hik.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.loong.loong.common.core.util.R;
import com.loong.loong.common.log.annotation.SysLog;
import com.loong.loong.hik.entity.HikCdcNormalAirCondition;
import com.loong.loong.hik.service.HikCdcNormalAirConditionService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.loong.loong.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 普通空调
 *
 * @author dxy
 * @date 2023-04-12 15:30:08
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/hikcdcnormalaircondition" )
@Api(value = "hikcdcnormalaircondition", tags = "普通空调管理")
public class HikCdcNormalAirConditionController {

    private final  HikCdcNormalAirConditionService hikCdcNormalAirConditionService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param hikCdcNormalAirCondition 普通空调
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcnormalaircondition_view')" )
    public R getHikCdcNormalAirConditionPage(Page page, HikCdcNormalAirCondition hikCdcNormalAirCondition) {
        return R.ok(hikCdcNormalAirConditionService.page(page, Wrappers.query(hikCdcNormalAirCondition)));
    }


    /**
     * 通过id查询普通空调
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcnormalaircondition_view')" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(hikCdcNormalAirConditionService.getById(id));
    }

    /**
     * 新增普通空调
     * @param hikCdcNormalAirCondition 普通空调
     * @return R
     */
    @ApiOperation(value = "新增普通空调", notes = "新增普通空调")
    @SysLog("新增普通空调" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdcnormalaircondition_add')" )
    public R save(@RequestBody HikCdcNormalAirCondition hikCdcNormalAirCondition) {
        return R.ok(hikCdcNormalAirConditionService.save(hikCdcNormalAirCondition));
    }

    /**
     * 修改普通空调
     * @param hikCdcNormalAirCondition 普通空调
     * @return R
     */
    @ApiOperation(value = "修改普通空调", notes = "修改普通空调")
    @SysLog("修改普通空调" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdcnormalaircondition_edit')" )
    public R updateById(@RequestBody HikCdcNormalAirCondition hikCdcNormalAirCondition) {
        return R.ok(hikCdcNormalAirConditionService.updateById(hikCdcNormalAirCondition));
    }

    /**
     * 通过id删除普通空调
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除普通空调", notes = "通过id删除普通空调")
    @SysLog("通过id删除普通空调" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcnormalaircondition_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(hikCdcNormalAirConditionService.removeById(id));
    }


    /**
     * 导出excel 表格
     * @param hikCdcNormalAirCondition 查询条件
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('hik_hikcdcnormalaircondition_export')" )
    public List<HikCdcNormalAirCondition> export(HikCdcNormalAirCondition hikCdcNormalAirCondition) {
        return hikCdcNormalAirConditionService.list(Wrappers.query(hikCdcNormalAirCondition));
    }
}
